namespace SharpTalk.Client.WpfApplication.ViewModels
{
    using Views;

    public sealed class ChatRoomJoinViewModel : ViewModelBase<IChatRoomJoinView>
    {
        private string _chatRoomName;

        public ChatRoomJoinViewModel(IChatRoomJoinView view) : base(view)
        {
            view.DataContext = this;
            view.Title = Resources.Messages.label_join;
            view.Icon = Helpers.LoadImage("chat_24.png");
        }
        
        public string ChatRoomName
        {
            get { return _chatRoomName; }
            set
            {
                _chatRoomName = value; 
                NotifyPropertyChange(()=> ChatRoomName);
                NotifyPropertyChange(() => CanJoin);
            }
        }

        public byte[] PasswordHash
        {
            get { return Core.Services.SecurityServices.GetHashValue(View.GetPassword()); } 
        }

        public bool CanJoin
        {
            get { return !string.IsNullOrEmpty(ChatRoomName); }
        }
    }
}